package collection;

import java.util.*;

public class homework1 {
    public static void main(String[] args) {

        List<String> list = new ArrayList<>();
        list.add("mjh");
        list.add("qqq");
        list.add("www");
        list.add("eee");
        list.add("rrr");
        list.add("ttt");
        System.out.println(list.get(3));
        list.set(3, "mjy");
        System.out.println(list.get(3));
        list.remove(3);
        System.out.println(list);
        System.out.println(list.subList(2, 4));
        Collections.sort(list);
        System.out.println(list);
        Collections.reverse(list);
        System.out.println(list);

        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length() - o2.length();
            }
        });
        System.out.println(list);


        List<Point> point = new ArrayList<>();
        point.add(new Point(1, 2));
        point.add(new Point(3, 4));
        point.add(new Point(5, 6));
        point.add(new Point(7, 8));
        point.add(new Point(9, 0));
        System.out.println(point);
        Collections.sort(point, new Comparator<Point>() {

            public int compare(Point o1, Point o2) {
                return o2.getX() - o1.getX();
            }
        });
        System.out.println(point);
        List<String> list1 = new ArrayList<>();
        list1.add("wangkejing");
        list1.add("马嘉豪");
        list1.add("woainimenooooooo");
        Collections.sort(list1, (o1, o2) -> o1.length() - o2.length()
        );
        System.out.println(list1);
        Collections.sort(list1, (o1, o2) ->
                o2.length() - o1.length()
        );
        System.out.println(list1);

        List<Point> po=new ArrayList<>();
        po.add(new Point(1,2));
        po.add(new Point(3,4));
        po.add(new Point(5,6));
        po.add(new Point(7,8));
        po.add(new Point(9,0));
        po.add(new Point(1,2));
        System.out.println(po);
        Set<Point> set=new HashSet<>();
        set.addAll(po);
        System.out.println(set);




    }
}
